import Cookies from "js-cookie";

const uToken = "u_token";

const darkMode = "dark_mode";

export function getToken() {
  return Cookies.get(uToken) || "";
}

// expires 超期时间 单位日
export function setToken(token) {
  Cookies.set(uToken, token, { expires: 1 });
}

export function removeToken() {
  return Cookies.remove(uToken);
}

export function removeAll() {
  return Cookies.Cookies.removeAll();
}

export function setDarkMode(mode) {
  return Cookies.set(darkMode, mode, { expires: 365 });
}

export function getDarkMode() {
  return !(
    Cookies.get(darkMode) === undefined || "false" === Cookies.get(darkMode)
  );
}
